#!/bin/bash
FILE_PATTERN=tempfile_XXXXXX.txt
DIR_PATTERN=tempdir_XXXxXXX.d

FILE_NAME=$(./mktemp $FILE_PATTERN)
DIR_NAME=$(./mktemp -d $DIR_PATTERN)

PASS=0

if [ -f $FILE_NAME ]; then
    echo "file $FILE_NAME created by mktemp is exist."
else 
    echo "file $FILE_NAME created by mktemp is not exist."
    PASS=1
fi

if [ -d $DIR_NAME ]; then
    echo "dir $DIR_NAME created by mktemp is exist.";
else 
    echo "dir $DIR_NAME created by mktemp is not exist.";
    PASS=1
fi 

sleep 1s

echo "clearing test files."
rm $FILE_NAME
rm -r $DIR_NAME

if [ $PASS -eq 0 ]; then
    echo "test pass."
else 
    echo "test failure."
fi

